package com.dhecp.project.system.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dhecp.common.core.controller.BaseController;
import com.dhecp.common.core.page.TableDataInfo;
import com.dhecp.core.constant.ModuleTable;
import com.dhecp.project.flowable.service.ActProcessTaskService;
import com.dhecp.project.system.service.SysModuleTaskService;

/**
 * 功能任务 控制层
 * @author DH-LWL
 * @version 2020年12月19日
 */
@Controller
@RequestMapping("/system/moduletask")
public class SysModuleTaskController extends BaseController{
	
    private String moduleTable = ModuleTable.MODULE_TASK;
    
    @Autowired
    private SysModuleTaskService moduleTaskService;
    
    @Autowired
    private ActProcessTaskService actProcessTaskService;
	
	/**
	 * 查询未处理任务数
	 * @param params
	 * @return
	 * @author DH-Xxj
	 */
	@GetMapping("/listwcls")
    @ResponseBody
    public TableDataInfo listWcls(@RequestParam Map<String, Object> params) {
		params.put("moduleTable", moduleTable);
        long actCount = 0;		//流程任务数
		Integer taskCount = 0;	//功能任务数
		Integer planCount = 0;	//计划数量
		Integer finishCount = 0;//总结数量
        List<Map<String, Object>> taskCountList =  new ArrayList<Map<String, Object>>();
        try {
        	actCount = actProcessTaskService.queryCurrentUserTodoActRuntimeTaskCount(1);
        	taskCount = moduleTaskService.queryModuleTaskWcls(params);
        	planCount = moduleTaskService.queryModuleTaskPlans(params);
        	finishCount = moduleTaskService.queryModuleTaskFinishs(params);
        	Map<String, Object> taskCountMap = new HashMap<String, Object>();
        	taskCountMap.put("actCount", actCount);
        	taskCountMap.put("taskCount", taskCount);
        	taskCountMap.put("planCount", planCount);
        	taskCountMap.put("finishCount", finishCount);
        	taskCountList.add(taskCountMap);
        } catch (Exception e) {
            e.printStackTrace();
            return getDataTable(this.getExceptionMessage(e).toString());            
        }
        return getDataTable(taskCountList);
    }
	
}
